/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: jse2302 - T3
 * <p>Powered by webrx On 2023-06-29 17:29:32
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T3 implements Runnable {
    public static void main(String[] args) {
        T3 t = new T3();
        var tt1 = new Thread(t, "线程一");
        var tt2 = new Thread(t, "线程二");
        var tt3 = new Thread(t, "线程三");
        tt1.start();
        tt2.start();
        tt3.start();
    }

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                try {
                    Thread.sleep(2000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            //获取当前线程名称输出
            System.out.println(Thread.currentThread().getName() + "/" + Thread.activeCount());
        }
    }
}
